import { FormSchema } from '/@/components/Form';
import { h } from 'vue';
import { uploadApi } from '/@/api/sys/upload';

export const formSchema: FormSchema[] = [
  {
    field: 'companyName',
    label: '公司名称',
    component: 'Input',
    required: true,
    colProps: { span: 12 },
  },
  {
    field: 'address',
    label: '公司地址',
    component: 'Input',
    required: true,
    colProps: { span: 12 },
  },
  {
    field: 'phone',
    label: '联系电话',
    component: 'Input',
    required: true,
    colProps: { span: 12 },
  },
  {
    field: 'wxChat',
    label: '微信',
    component: 'Input',
    required: false,
    colProps: { span: 12 },
  },
  {
    field: 'whatsApp',
    label: 'whatsApp',
    component: 'Input',
    required: false,
    colProps: { span: 12 },
  },
  {
    field: 'email',
    label: '邮箱',
    component: 'Input',
    required: false,
    colProps: { span: 12 },
  },
  {
    field: 'website',
    label: '网址',
    component: 'Input',
    required: false,
    colProps: { span: 12 },
  },
  {
    field: 'logoUrl_p',
    component: 'Input',
    label: 'logo',
    colProps: {
      span: 8,
    },
    render: ({ model }) => {
      return h('img', {
        src: model.logoUrl,
        style: {
          border: '1px solid #d9d9d9',
          padding: '10px',
          'border-radius': '2px',
          'min-height': '100px',
          'background-color': '#f5f5f5',
          cursor: 'not-allowed',
          height: '80px',
        },
      });
    },
  },
  {
    field: 'logoUrl',
    component: 'Upload',
    label: 'logo',
    helpMessage:'建议图片比例（ 宽16：高10 ）',
    colProps: {
      span: 8,
    },
    show: false,
    rules: [{ required: true, message: '请选择上传文件' }],
    componentProps: {
      api: uploadApi,
      maxNumber: 1,
      multiple: false,
      accept: ['image/*'],
      uploadParams: {
        videoFlag: false,
      },
    },
  },
  {
    field: 'introduce',
    component: 'Input',
    label: '公司介绍',
    // show: false,
    rules: [{ required: true }],
    render: ({ model }) => {
      console.log(model);
      return h('div', {
        innerHTML: model.introduce,
        style: {
          border: '1px solid #d9d9d9',
          padding: '10px',
          'border-radius': '2px',
          'min-height': '100px',
          'background-color': '#f5f5f5',
          cursor: 'not-allowed',
        },
      });
    },
  },
  {
    field: 'materialDescription',
    label: '原材料简要说明',
    component: 'InputTextArea',
    required: false,
  },
  {
    field: 'customDescription',
    label: '定制品简要说明',
    component: 'InputTextArea',
    required: false,
  },
  {
    field: 'detail',
    label: '其他说明',
    component: 'InputTextArea',
    show: false,
    required: false,
  },
];
